#include "dlg_bookau.h"
#include "ui_dlg_bookau.h"
#include "lib/sql.h"

Dlg_bookAU::Dlg_bookAU(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dlg_bookAU)
{
    ui->setupUi(this);
}

Dlg_bookAU::~Dlg_bookAU()
{
    delete ui;
}

void Dlg_bookAU::types(int id)
{
    m_id = id;
}

void Dlg_bookAU::on_btn_sure_clicked()
{
    QStringList l;
    l<<QString::number(m_id);
    l<<ui->LE_name->text();
    l<<ui->comboBox->currentText();
    l<<ui->LE_catogory->text();
    l<<ui->LE_count->text();
    if(m_id == -1){
        //增加
        Sql::getinstance()->addBook(l);

    }else{
        //更新
        Sql::getinstance()->changeBook(l);
    }
    this->hide();
}


void Dlg_bookAU::on_btn_cancel_clicked()
{
    this->hide();
}

